package org.king.controller;

import javafx.fxml.FXML;
import javafx.scene.control.DatePicker;
import javafx.scene.control.Button;

import java.time.LocalDate;

public class SearchController {
    @FXML
    private DatePicker datePicker;
    @FXML
    private Button btnSearch;
    @FXML
    private Button btnCancel;

    private MainController mainController;

    public void setMainController(MainController mainController) {
        this.mainController = mainController;
    }

    @FXML
    private void initialize() {
        btnSearch.setOnAction(event -> {
            LocalDate selectedDate = datePicker.getValue();
            // 如果日期为空，传递null给MainController
            mainController.updateActivityList(selectedDate,0);
            ((javafx.stage.Stage) btnSearch.getScene().getWindow()).close();
        });

        btnCancel.setOnAction(event -> {
            ((javafx.stage.Stage) btnCancel.getScene().getWindow()).close();
        });
    }
}
